package com.fenghongzhang.day008view;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class Main3Activity extends AppCompatActivity {

    private ScrollView ss;
    private TextView text;
    private ListView lv;
    private TextView text1;
    private TextView text2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);


        ss = (ScrollView) findViewById(R.id.ss);
        text = (TextView) findViewById(R.id.text);
        lv = (ListView) findViewById(R.id.lv);
        text1 = (TextView) findViewById(R.id.text1);
        text2 = (TextView) findViewById(R.id.text2);


        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");
        list.add("1");

        ViewGroup.LayoutParams layoutParams = lv.getLayoutParams();
        layoutParams.height = 300;
        lv.setLayoutParams(layoutParams);

        lv.setAdapter(new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,list));

        lv.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                lv.getParent().requestDisallowInterceptTouchEvent(true);
                return false;
            }
        });

    }
}
